From: Camila Ayres Date: Tue, 14 Jan 2025 16:23:29 +0000 (+0100) Subject: Check for FoldersWithPlaceholders when migrating account's folders. X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~2^2~69^2~2 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success/%22http:/www.example.com/cgi/success?a=commitdiff_plain;h=59f1b6aa7d6bbe1b7b4fa3dd9c3cc0357ea6f2a3;p=nextcloud-desktop.git Check for FoldersWithPlaceholders when migrating account's folders. Improve logs. Signed-off-by: Camila Ayres --- diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index 9b279bbb0..6f84af9ad 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -42,6 +42,7 @@ namespace { constexpr auto settingsAccountsC = "Accounts"; constexpr auto settingsFoldersC = "Folders"; +constexpr auto settingsFoldersWithPlaceholdersC = "FoldersWithPlaceholders"; constexpr auto settingsVersionC = "version"; constexpr auto maxFoldersVersion = 1; @@ -526,89 +527,97 @@ void FolderMan::setupLegacyFolder(const QString &fileNamePath, AccountState *acc return; } - settings.beginGroup(settingsAccountsC); - qCDebug(lcFolderMan) << "try to migrate accountId:" << accountState->account()->id(); - settings.beginGroup(accountState->account()->id()); - settings.beginGroup(settingsFoldersC); - - if (settings.childGroups().isEmpty()) { - qCDebug(lcFolderMan) << "there are no legacy folders for accountId:" << accountState->account()->id(); - return; - } - - const auto childGroups = settings.childGroups(); - for (const auto &alias : childGroups) { - settings.beginGroup(alias); - qCDebug(lcFolderMan) << "try to migrate folder alias:" << alias; - - const auto path = settings.value(QLatin1String("localPath")).toString(); - const auto targetPath = settings.value(QLatin1String("targetPath")).toString(); - const auto journalPath = settings.value(QLatin1String("journalPath")).toString(); - const auto paused = settings.value(QLatin1String("paused"), false).toBool(); - const auto ignoreHiddenFiles = settings.value(QLatin1String("ignoreHiddenFiles"), false).toBool(); - - if (path.isEmpty()) { - qCDebug(lcFolderMan) << "localPath is empty"; - settings.endGroup(); - continue; - } - - if (targetPath.isEmpty()) { - qCDebug(lcFolderMan) << "targetPath is empty"; - settings.endGroup(); - continue; + auto migrateFoldersGroup = [&](const QString &folderGroupName) { + const auto childGroups = settings.childGroups(); + if (childGroups.isEmpty()) { + qCDebug(lcFolderMan) << "There are no" << folderGroupName << "to migrate from account" << accountState->account()->id(); + return; } + for (const auto &alias : childGroups) { + settings.beginGroup(alias); + qCDebug(lcFolderMan) << "try to migrate" << folderGroupName << "alias:" << alias; + + const auto path = settings.value(QLatin1String("localPath")).toString(); + const auto targetPath = settings.value(QLatin1String("targetPath")).toString(); + const auto journalPath = settings.value(QLatin1String("journalPath")).toString(); + const auto paused = settings.value(QLatin1String("paused"), false).toBool(); + const auto ignoreHiddenFiles = settings.value(QLatin1String("ignoreHiddenFiles"), false).toBool(); + + if (path.isEmpty()) { + qCDebug(lcFolderMan) << "localPath is empty"; + settings.endGroup(); + continue; + } - if (journalPath.isEmpty()) { - qCDebug(lcFolderMan) << "journalPath is empty"; - settings.endGroup(); - continue; - } + if (targetPath.isEmpty()) { + qCDebug(lcFolderMan) << "targetPath is empty"; + settings.endGroup(); + continue; + } - FolderDefinition folderDefinition; - folderDefinition.alias = alias; - folderDefinition.localPath = path; - folderDefinition.targetPath = targetPath; - folderDefinition.journalPath = journalPath; - folderDefinition.paused = paused; - folderDefinition.ignoreHiddenFiles = ignoreHiddenFiles; - - if (const auto folder = addFolderInternal(folderDefinition, accountState, std::make_unique())) { - auto ok = true; - auto legacyBlacklist = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, - &ok); - if (!ok) { - qCInfo(lcFolderMan) << "There was a problem retrieving the database selective sync for " << folder; + if (journalPath.isEmpty()) { + qCDebug(lcFolderMan) << "journalPath is empty"; + settings.endGroup(); + continue; } - legacyBlacklist << settings.value(QLatin1String("blackList")).toStringList(); - if (!legacyBlacklist.isEmpty()) { - qCInfo(lcFolderMan) << "Legacy selective sync list found:" << legacyBlacklist; - for (const auto &legacyFolder : legacyBlacklist) { - folder->migrateBlackListPath(legacyFolder); + qCDebug(lcFolderMan) << folderGroupName << "located at" << path; + + FolderDefinition folderDefinition; + folderDefinition.alias = alias; + folderDefinition.localPath = path; + folderDefinition.targetPath = targetPath; + folderDefinition.journalPath = journalPath; + folderDefinition.paused = paused; + folderDefinition.ignoreHiddenFiles = ignoreHiddenFiles; + + if (const auto folder = addFolderInternal(folderDefinition, accountState, std::make_unique())) { + auto ok = true; + auto legacyBlacklist = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, + &ok); + if (!ok) { + qCInfo(lcFolderMan) << "There was a problem retrieving the database selective sync for " << folder; + } + + legacyBlacklist << settings.value(QLatin1String("blackList")).toStringList(); + if (!legacyBlacklist.isEmpty()) { + qCInfo(lcFolderMan) << "Legacy selective sync list found:" << legacyBlacklist; + for (const auto &legacyFolder : legacyBlacklist) { + folder->migrateBlackListPath(legacyFolder); + } + settings.remove(QLatin1String("blackList")); } - settings.remove(QLatin1String("blackList")); - } - folder->saveToSettings(); + folder->saveToSettings(); - qCInfo(lcFolderMan) << "Migrated!" << folder->path(); - settings.sync(); + qCInfo(lcFolderMan) << "Migrated!" << folder->path(); + settings.sync(); - if (!folder) { - continue; - } + if (!folder) { + continue; + } - scheduleFolder(folder); - emit folderSyncStateChange(folder); + scheduleFolder(folder); + emit folderSyncStateChange(folder); + } + settings.endGroup(); // folder alias } + }; - settings.endGroup(); - } + settings.beginGroup(settingsAccountsC); + qCDebug(lcFolderMan) << "try to migrate accountId:" << accountState->account()->id(); + settings.beginGroup(accountState->account()->id()); + settings.beginGroup(settingsFoldersWithPlaceholdersC); + migrateFoldersGroup(settingsFoldersWithPlaceholdersC); settings.endGroup(); + + settings.beginGroup(settingsFoldersC); + migrateFoldersGroup(settingsFoldersC); settings.endGroup(); + settings.endGroup(); + settings.endGroup(); return; }